#pragma once
#include <string>
#include <map>
#include <functional>
#include <climits>
class Task
{
public:
    Task() = default;
    Task(int left, int right, char oper)
    :_left(left), _right(right), _oper(oper), _result(0)
    {
        cmdOP = 
        {
            {'+', [](int x, int y){return x + y;}},
            {'-', [](int x, int y){return x - y;}},
            {'*', [](int x, int y){return x * y;}},
            {'/', [](int x, int y){return y == 0 ? INT_MAX : x / y;}},
        };
    }
    
    void Run()
    {
        _result = cmdOP[_oper](_left, _right);
    }
    void operator()()
    {
        Run();
    }
    std::string PrintTask()
    {
        std::string tmp;
        tmp += std::to_string(_left);
        tmp += _oper;
        tmp += std::to_string(_right);
        tmp += '=';
        return tmp;
    }
    std::string PrintResult()
    {
        std::string tmp;
        tmp += std::to_string(_left);
        tmp += _oper;
        tmp += std::to_string(_right);
        tmp += '=';
        tmp += std::to_string(_result);
        return tmp;
    }
static const std::string opers;
private:
    int _left;
    int _right;
    char _oper;
    int _result;
    std::map<char, std::function<int(int, int)>> cmdOP;
};
const std::string Task::opers="+-*/";